<template>
  <div>
    <!-- <right-tree
      v-if="list && list.length"
      :list="list"
      @changeData="changeData"
    ></right-tree> -->
  </div>
</template>
<script>
// import RightTree from "./RightTree";

export default {
  components: {
    // RightTree,
  },
  data() {
    return {
      list: [],
      flag: true,
      loading: false,
    };
  },
  watch: {},
  mounted() {
    this.getNodeList(this.flag);
    // this.$eventBus.$on("changeData", (value) => {
    //   this.getNodeList(value);
    // });
  },
  created() {},
  methods: {
    changeData(value) {
      this.getNodeList(value);
    },
    /**
     * 获取列表数据
     */
    async getNodeList(flag) {
      this.loading = true;
      try {
        this.list.splice(0);

        setTimeout(() => {
          if (flag) {
            this.list = [
              {
                id: "1",
                name: "标题",
                checked: true,
                children: [
                  {
                    id: "1-1",
                    name: "标题",
                    checked: true,
                    child: [
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:2",
                      },
                    ],
                  },
                  {
                    id: "1-2",
                    name: "标题",
                    checked: false,
                  },
                  {
                    id: "1-3",
                    name: "标题",
                    checked: true,
                    child: [
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:2",
                      },
                    ],
                  },
                  {
                    id: "1-4",
                    name: "点击更多",
                    checked: false,
                  },
                ],
              },
            ];
          } else {
            this.list = [
              {
                id: "1",
                name: "标题",
                checked: true,
                children: [
                  {
                    id: "1-1",
                    name: "标题",
                    checked: true,
                    child: [
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:2",
                      },
                    ],
                  },
                  {
                    id: "1-2",
                    name: "标题",
                    checked: false,
                  },
                  {
                    id: "1-3",
                    name: "标题",
                    checked: true,
                    child: [
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:2",
                      },
                    ],
                  },
                  {
                    id: "1-4",
                    name: "标题",
                    checked: true,
                    child: [
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:2",
                      },
                    ],
                  },
                  {
                    id: "1-5",
                    name: "标题",
                    checked: true,
                    child: [
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:1",
                      },
                      {
                        name: "1:2",
                      },
                    ],
                  },
                ],
              },
            ];
          }
        }, 1000);
      } catch (e) {
        console.log("e", e);
      }
      this.loading = false;
    },
  },
};
</script>

